﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using XDesigner.ORM;

namespace XDesigner.ORM.Test
{
    public partial class frmReadCustomers : Form
    {
        public frmReadCustomers()
        {
            InitializeComponent();
        }

        private void btnRefresh_Click(object sender, EventArgs e)
        {
            lvwCustomers.Items.Clear();
            CustomerClass[] cus = (CustomerClass[])Program.ORM.ReadInstances(
                typeof(CustomerClass),
                "Select * from customers" );
            if (cus != null && cus.Length > 0)
            {
                foreach (CustomerClass cur in cus)
                {
                    ListViewItem item = new ListViewItem(cur.ID.ToString());
                    item.SubItems.Add(cur.CompanyName);
                    item.SubItems.Add(cur.ContactName);
                    item.SubItems.Add(cur.Address);
                    item.SubItems.Add(cur.City);
                    item.SubItems.Add(cur.Region);
                    item.Tag = cur;
                    lvwCustomers.Items.Add(item);
                }
            }
        }

    }
}